* rules:
* |[
* <object class="GtkFileFilter">
+ * <property name="name" translatable="yes">Text and Images</property>
* <mime-types>
* <mime-type>text/plain</mime-type>
* <mime-type>image/ *</mime-type>
} u;
};
+enum {
+ PROP_0,
+ PROP_NAME,
+ NUM_PROPERTIES
+};
+
+static GParamSpec *props[NUM_PROPERTIES] = { NULL, };
+
+
+static void gtk_file_filter_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gtk_file_filter_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+
static void gtk_file_filter_finalize (GObject *object);
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+ gobject_class->set_property = gtk_file_filter_set_property;
+ gobject_class->get_property = gtk_file_filter_get_property;
gobject_class->finalize = gtk_file_filter_finalize;
+
+ /**
+ * GtkFileFilter:name:
+ *
+ * The human-readable name of the filter.
+ *
+ * This is the string that will be displayed in the file selector user
+ * interface if there is a selectable list of filters.
+ */
+ props[PROP_NAME] =
+ g_param_spec_string ("name",
+ P_("Name"),
+ P_("The human-readable name for this filter"),
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+
+ g_object_class_install_properties (gobject_class, NUM_PROPERTIES, props);
}
static void
g_slice_free (FilterRule, rule);
}
+static void
+gtk_file_filter_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkFileFilter *filter = GTK_FILE_FILTER (object);
+
+ switch (prop_id)
+ {
+ case PROP_NAME:
+ gtk_file_filter_set_name (filter, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_file_filter_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkFileFilter *filter = GTK_FILE_FILTER (object);
+
+ switch (prop_id)
+ {
+ case PROP_NAME:
+ g_value_set_string (value, filter->name);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
static void
gtk_file_filter_finalize (GObject *object)
{
const gchar *name)
{
g_return_if_fail (GTK_IS_FILE_FILTER (filter));
-
- g_free (filter->name);
+ if (g_strcmp0 (filter->name, name) == 0)
+ return;
+
+ g_free (filter->name);
filter->name = g_strdup (name);
+
+ g_object_notify_by_pspec (G_OBJECT (filter), props[PROP_NAME]);
}
/**
const gchar buffer[] =
"<interface>"
" <object class='GtkFileFilter' id='filter1'>"
+ " <property name='name'>Text and Images</property>"
" <mime-types>"
" <mime-type>text/plain</mime-type>"
" <mime-type>image/*</mime-type>"
obj = gtk_builder_get_object (builder, "filter1");
g_assert (GTK_IS_FILE_FILTER (obj));
filter = GTK_FILE_FILTER (obj);
- g_assert_cmpstr (gtk_file_filter_get_name (filter), ==, "filter1");
+ g_assert_cmpstr (gtk_file_filter_get_name (filter), ==, "Text and Images");
g_assert (gtk_file_filter_get_needed (filter) & GTK_FILE_FILTER_MIME_TYPE);
g_assert (gtk_file_filter_get_needed (filter) & GTK_FILE_FILTER_DISPLAY_NAME);